<!DOCTYPE html>
<html lang="zh" xmlns:th="https://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no">
	<title>微笑计划管理后台 </title>
	<!-- BEGIN GLOBAL MANDATORY STYLES -->
	<link href="https://fonts.googleapis.com/css?family=Nunito:400,600,700" rel="stylesheet">
	<link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
	<link href="/assets/css/plugins.css" rel="stylesheet" type="text/css" />
	<!-- END GLOBAL MANDATORY STYLES -->

	<!-- BEGIN PAGE LEVEL CUSTOM STYLES -->
	<link rel="stylesheet" type="text/css" href="/plugins/table/datatable/datatables.css">
	<link rel="stylesheet" type="text/css" href="/plugins/table/datatable/custom_dt_html5.css">
	<link rel="stylesheet" type="text/css" href="/plugins/table/datatable/dt-global_style.css">

	<script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.config.js"></script>
	<script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.all.min.js"> </script>
	<script type="text/javascript" charset="utf-8" src="/ueditor/lang/zh-cn/zh-cn.js"></script>

	<link th:href="@{/plugins/notification/snackbar/snackbar.min.css}" rel="stylesheet" type="text/css" />
	<!-- END PAGE LEVEL CUSTOM STYLES -->

	<!-- BEGIN PAGE LEVEL STYLES -->
	<link href="/assets/css/scrollspyNav.css" rel="stylesheet" type="text/css" />
	<link href="/plugins/file-upload/file-upload-with-preview.min.css" rel="stylesheet" type="text/css" />
	<!-- END PAGE LEVEL STYLES -->

	<!--  BEGIN CUSTOM STYLE FILE  -->
	<link rel="stylesheet" type="text/css" href="/plugins/editors/quill/quill.snow.css">


	<!-- Font Awesome -->
	<link href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
	<!-- Ionicons -->
	<link href="https://cdn.staticfile.org/ionicons/4.1.2/css/ionicons.min.css" rel="stylesheet">

	<link href="https://cdn.staticfile.org/codemirror/5.38.0/codemirror.min.css" rel="stylesheet">


	<link rel="stylesheet" type="text/css" href="/plugins/bootstrap-select/bootstrap-select.min.css">



	<!--  END CUSTOM STYLE FILE  -->
</head>
<style>
	img{
		width: auto;
		height: 50px;
	}
</style>
<body class="sidebar-noneoverflow">

<!--  BEGIN NAVBAR  -->
<div class="header-container fixed-top">
	<header class="header navbar navbar-expand-sm">
		<a href="javascript:void(0);" class="sidebarCollapse" data-placement="bottom"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu"><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line></svg></a>
		<ul class="navbar-item flex-row">
		</ul>
		<ul class="navbar-item flex-row search-ul">
		</ul>
		<ul class="navbar-item flex-row navbar-dropdown">
			<li class="nav-item dropdown user-profile-dropdown  order-lg-0 order-1">
				<a href="javascript:void(0);" class="nav-link dropdown-toggle user" id="userProfileDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
					<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-user"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>
				</a>
				<div class="dropdown-menu position-absolute" aria-labelledby="userProfileDropdown">
					<div class="">
						<div class="dropdown-item">
							<a class="" href="/admin/userinfo"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-user"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>个人资料</a>
						</div>
						<div class="dropdown-item">
							<a class="" href="/addmin/out"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-log-out"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"></path><polyline points="16 17 21 12 16 7"></polyline><line x1="21" y1="12" x2="9" y2="12"></line></svg>退出登录</a>
						</div>
					</div>
				</div>
			</li>
		</ul>
	</header>
</div>
<!--  END NAVBAR  -->

<!--  BEGIN MAIN CONTAINER  -->
<div class="main-container" id="container">

	<div class="overlay"></div>
	<div class="cs-overlay"></div>
	<div class="search-overlay"></div>

	<!--  BEGIN SIDEBAR  -->
	<div class="sidebar-wrapper sidebar-theme">

		<nav id="sidebar">

			<ul class="navbar-nav theme-brand flex-row  text-center">

				<li class="nav-item theme-text">
					<a href="/admin" class="nav-link"> 微笑计划 </a>
				</li>
				<li class="nav-item toggle-sidebar">
					<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left sidebarCollapse"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>
				</li>
			</ul>

			<div class="shadow-bottom"></div>


			<ul class="list-unstyled menu-categories" id="accordionExample">

				<li class="menu">
					<a href="#dashboard" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle collapsed">
						<div class="">
							<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
							<span>仪表盘</span>
						</div>
						<div>
							<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"><polyline points="9 18 15 12 9 6"></polyline></svg>
						</div>
					</a>
					<ul class="submenu recent-submenu mini-recent-submenu list-unstyled collapse" id="dashboard" data-parent="#accordionExample">
						<li class="active">
							<a href="/admin"> 数据统计 </a>
						</li>
					</ul>
				</li>

				<li class="menu ">
					<a href="#userMager" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle collapsed">
						<div class="">
							<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
							                                    <span>会员</span><span>会员</span>
						</div>
						<div>
							<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"><polyline points="9 18 15 12 9 6"></polyline></svg>
						</div>
					</a>
					<ul class="submenu recent-submenu mini-recent-submenu list-unstyled collapse" id="userMager" data-parent="#accordionExample">
						<li class="">
							<a href="/admin/userList"> 会员列表 </a>
						</li>
						<li class="">
							<a href="/admin/userListAngel"> 天使列表 </a>
						</li>
						<li class="">
							<a href="/admin/userListCity"> 市代列表 </a>
						</li>
						<li class="">
							<a href="/admin/userListProvince"> 省代列表 </a>
						</li>
						<li class="">
							<a href="/admin/userListPartner"> 分公司列表 </a>
						</li>
					</ul>
				</li>




				<li class="menu active">
					<a href="#shopMager" data-toggle="collapse" aria-expanded="true" class="dropdown-toggle ">
						<div class="">
							<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
							<span>商城</span>
						</div>
						<div>
							<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"><polyline points="9 18 15 12 9 6"></polyline></svg>
						</div>
					</a>
					<ul class="collapse submenu recent-submenu mini-recent-submenu list-unstyled show" id="shopMager" data-parent="#accordionExample">
						<li class="">
							<a href="/admin/shopGoodsMenu"> 商城分类 </a>
						</li>
						<li class="active">
							<a href="/admin/shopGoodsList"> 商品管理 </a>
						</li>
						<li class="">
							<a href="/admin/shopOrderList"> 订单管理 </a>
						</li>
					</ul>
				</li>


				<li class="menu">
					<a href="#uniappMager" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle collapsed">
						<div class="">
							<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
							<span>小程序</span>
						</div>
						<div>
							<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"><polyline points="9 18 15 12 9 6"></polyline></svg>
						</div>
					</a>
					<ul class="submenu recent-submenu mini-recent-submenu list-unstyled collapse" id="uniappMager" data-parent="#accordionExample">
						<li class="">
							<a href="/admin/uniIndex"> 首页排版 </a>
						</li>
						<li class="">
							<a href="/admin/uniSwiper"> 首页轮播 </a>
						</li>
						<li class="">
							<a href="/admin/uniHome"> 微笑计划排版 </a>
						</li>
					</ul>
				</li>


				<li class="menu">
					<a href="#articleMager" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle collapsed">
						<div class="">
							<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
							<span>文章管理</span>
						</div>
						<div>
							<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"><polyline points="9 18 15 12 9 6"></polyline></svg>
						</div>
					</a>
					<ul class="submenu recent-submenu mini-recent-submenu list-unstyled collapse" id="articleMager" data-parent="#accordionExample">
						<li class="">
							<a href="/admin/articleList"> 文章列表 </a>
						</li>
					</ul>
				</li>

				<li class="menu">
					<a href="#moneyMager" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle collapsed">
						<div class="">
							<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
							<span>资金记录</span>
						</div>
						<div>
							<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"><polyline points="9 18 15 12 9 6"></polyline></svg>
						</div>
					</a>
					<ul class="submenu recent-submenu mini-recent-submenu list-unstyled collapse" id="moneyMager" data-parent="#accordionExample">
						<li class="">
							<a href="/admin/shopCzList"> 充值记录 </a>
						</li>
						<li class="">
							<a href="/admin/shopSyList"> 收益记录 </a>
						</li>
					</ul>
				</li>

			</ul>
		</nav>

	</div>
	<!--  END SIDEBAR  -->

	<!--  BEGIN CONTENT AREA  -->
	<div id="content" class="main-content">


		<div class="layout-px-spacing">

			<div class="row layout-top-spacing" id="cancel-row">

				<div class="col-xl-12 col-lg-12 col-sm-12  layout-spacing">
					<div class="widget-content widget-content-area br-6">
						<!--<form id="addForm" action="/admin/addGoods" method="post">-->

						<button class="btn btn-primary mb-2" onclick="window.history.back();">返回</button>


						<div class="input-group mb-4 col-xl-6 col-lg-6 col-sm-6">
							<div class="input-group-prepend">
								<span class="input-group-text" id="basic-addon5">商品名称</span>
							</div>
							<input type="text" class="form-control" name="goodsName" placeholder="商品名称" aria-label="商品名称">
						</div>
						<div class="input-group mb-4 col-xl-6 col-lg-6 col-sm-6">
							<div class="input-group-prepend">
								<span class="input-group-text" id="basic-addon6">商品价格  (单位:元)</span>
							</div>
							<input type="number" class="form-control" name="goodsPrices" placeholder="商品价格" aria-label="商品价格">
						</div>



						<div class="input-group mb-4 col-xl-6 col-lg-6 col-sm-6">
							<div class="input-group-prepend">
								<span class="input-group-text" >选择分类</span>
							</div>
							<select class="select2" id="menuName">
								<option th:each="opt:${goodsMenu}" th:attr="mid=${opt.id}" th:text="${opt.menuName}" ></option>
							</select>
						</div>



						<div class="input-group mb-4 col-xl-6 col-lg-6 col-sm-6">
							<div class="input-group-prepend">
								<span class="input-group-text" id="sorts">位置排序</span>
							</div>
							<input type="text" class="form-control" name="goodsSort" value="0" placeholder="排序" aria-label="排序">
						</div>

						<div class="row">
							<div class="input-group mb-4 col-xl-6 col-lg-6 col-sm-6">
								<h5> 类型 </h5>
							</div>
						</div>

						<div class="input-group mb-4 col-xl-10 col-lg-10 col-sm-10" id="leixing" style="margin:10px">
							<label style="width: 100px;font-size: 18px"><input type="radio" name="type" value="0" checked="checked"/> 返佣</label>
							<label style="width: 100px;font-size: 18px"><input type="radio" name="type" value="1"/> 门槛</label>
						</div>

						<div id="fanyong">
							<div class="input-group mb-4 col-xl-6 col-lg-6 col-sm-6">
								<div class="input-group-prepend">
									<span class="input-group-text">天使价格</span>
								</div>
								<input type="number" value="0.00" class="form-control" name="angelPrice" placeholder="天使价格" aria-label="天使价格">
								<div class="input-group-prepend">
									<span class="input-group-text">返佣</span>
								</div>
								<input type="number" value="0.00" class="form-control" name="priceAngel" placeholder="天使返佣" aria-label="天使返佣">
							</div>

							<div class="input-group mb-4 col-xl-6 col-lg-6 col-sm-6">
								<div class="input-group-prepend">
									<span class="input-group-text">市代价格</span>
								</div>
								<input type="number" value="0.00" class="form-control" name="cityPrice" placeholder="市代价格" aria-label="市代价格">
								<div class="input-group-prepend">
									<span class="input-group-text">返佣</span>
								</div>
								<input type="number" value="0.00" class="form-control" name="priceCity" placeholder="市代返佣" aria-label="市代返佣">
							</div>

							<div class="input-group mb-4 col-xl-6 col-lg-6 col-sm-6">
								<div class="input-group-prepend">
									<span class="input-group-text">省代价格</span>
								</div>
								<input type="number" value="0.00" class="form-control" name="provincePrice" placeholder="省代价格" aria-label="省代价格">
								<div class="input-group-prepend">
									<span class="input-group-text">返佣</span>
								</div>
								<input type="number" value="0.00" class="form-control" name="priceProvince" placeholder="省代返佣" aria-label="省代返佣">
							</div>

							<div class="input-group mb-4 col-xl-6 col-lg-6 col-sm-6">
								<div class="input-group-prepend">
									<span class="input-group-text" >分公司价格</span>
								</div>
								<input type="number" value="0.00" class="form-control" name="partnerPrice" placeholder="分公司价格" aria-label="分公司价格">
								<div class="input-group-prepend">
									<span class="input-group-text" >返佣</span>
								</div>
								<input type="number" value="0.00" class="form-control" name="pricePartner" placeholder="分公司返佣" aria-label="分公司返佣">
							</div>
						</div>







						<div class="row">
							<div class="col-xl-12 col-md-12 col-sm-12 col-12">
								<h4> 商品主图 </h4>
							</div>
						</div>

						<div class="input-group mb-4 col-xl-10 col-lg-10 col-sm-10" style="margin:10px">
							<div id="imgIndexSelect" style="width:100%">
								<input type="file" id="imgIndex" accept="image/*">
								<button class="badge-secondary" onclick="uploadImg('imgIndex')">上传</button>
							</div>
							<div id="imgIndexShowDiv" style="display:inline-grid;display:none">
								<div id="imgIndexShow" style="width:100%">
								</div>
								<div style="text-align: center">
									<a onclick="delImg('imgIndex')">删除</a>
								</div>
							</div>
						</div>

						<div class="widget-header">
							<div class="row">
								<div class="col-xl-12 col-md-12 col-sm-12 col-12">
									<h4> 商品轮播图 </h4>
								</div>
							</div>
						</div>
						<div class="input-group mb-4 col-xl-10 col-lg-10 col-sm-10" style="margin:10px">
							<div id="imgSwiperSelect" style="width:100%">
								<input type="file" id="imgSwiper" accept="image/*">
							</div>
							<div id="imgSwiperShowDiv" style="width:100%;margin-top: 10px">

							</div>
						</div>

						<div class="widget-header">
							<div class="row">
								<div class="col-xl-12 col-md-12 col-sm-12 col-12">
									<h4> 商品详情 </h4>
								</div>
							</div>
						</div>
						<div>
							<div id="goodsContent" style="width:100%;height: 400px">

							</div>
						</div>

						<button class="btn btn-primary mb-2" style="margin-top: 30px" onclick="add()">保存</button>
						<!--</form>-->
					</div>
				</div>

			</div>

		</div>
		<div class="footer-wrapper">
			<div class="footer-section f-section-1">
				<p class="">Copyright © 2021 郑州灵之动网络科技有限公司</p>
			</div>

		</div>
	</div>
	<!--  END CONTENT AREA  -->

</div>
<!-- END MAIN CONTAINER -->



<!-- BEGIN GLOBAL MANDATORY SCRIPTS -->
<script th:src="@{/plugins/notification/snackbar/snackbar.min.js}"></script>
<script src="/assets/js/libs/jquery-3.1.1.min.js"></script>
<script src="/bootstrap/js/popper.min.js"></script>
<script src="/bootstrap/js/bootstrap.min.js"></script>
<script src="/plugins/perfect-scrollbar/perfect-scrollbar.min.js"></script>
<script src="/assets/js/app.js"></script>
<script src="/plugins/file-upload/file-upload-with-preview.min.js"></script>
<script src="/plugins/editors/quill/quill.js"></script>
<script src="/assets/js/scrollspyNav.js"></script>
<script src="/plugins/bootstrap-select/bootstrap-select.min.js"></script>

<script>


	var ue = UE.getEditor('goodsContent');

	UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
	UE.Editor.prototype.getActionUrl = function(action) {
		if (action == 'uploadimage'){
			return '/uploadimage'; /* 你自己的图片上传action */
		}else{
			return this._bkGetActionUrl.call(this, action);
		}
	};

	let lx = 0;

	$(function () {
		$("#leixing :radio").on('click', function () {
			lx = $(this).val();
			if(lx == 1){
				$("#fanyong").hide();
			}else{
				$("#fanyong").show();
			}
		})
		var $swiper =  $("#imgSwiper");
		$swiper.change(function () {
			if($(this).val() != ""){
				var formdata=new FormData();
				var img = $swiper.get(0).files[0];
				if (!img) {
					Snackbar.show({
						text: "请选择图片",
						pos: 'top-center'
					});
					return false;
				}
				formdata.append('img', img);
				$.ajax({
					async: false,
					type: 'POST',
					url: "/admin/uploadImg",
					dataType: 'json',
					data: formdata,
					contentType:false,//ajax上传图片需要添加
					processData:false,//ajax上传图片需要添加
					success: function (data) {
						if(data.code == "200"){
							$("#imgSwiperShowDiv").append("<div style=\"display: inline-grid;margin-right: 20px\"><div style=\"width:100%\"><img name='goodsSwiper' src='"+data.data+
									"' style='height:100px'/></div><div style=\"text-align: center\"><a onclick=\"delSwiperImg(this)\">删除</a></div></div>");
							$('#imgSwiper').val("");
						}
						else {
							$("#imgSwiperShowDiv").html("上传失败");
						}
					},
					error: function (e) {
						alert("error");
					}
				})
			}
		})


	})

	function uploadImg(imgItem) {
		var formdata=new FormData();
		var img = $('#' + imgItem).get(0).files[0];
		if (!img) {
			Snackbar.show({
				text: '请选择图片',
				pos: 'top-center'
			});
			return false;
		}
		formdata.append('img', img);
		$.ajax({
			async: false,
			type: 'POST',
			url: "/admin/uploadImg",
			dataType: 'json',
			data: formdata,
			contentType:false,//ajax上传图片需要添加
			processData:false,//ajax上传图片需要添加
			success: function (data) {
				if(data.code == "200"){
					$("#" + imgItem + "ShowDiv").show();
					$("#" + imgItem + "Show").html("<img name='goodsImg' src='"+data.data+"' style='height:100px'/>");
					$("#" + imgItem + "Select").hide();
					$('#' + imgItem).val("");
				}
				else {
					$("#imgShow").html("上传失败");
				}
			},
			error: function (e) {
				alert("error");
			}
		})
	}
	function delImg(imgItem) {
		$("#" + imgItem + "ShowDiv").hide();
		$("#" + imgItem + "Select").show();
	}
	function uploadSwiperImg() {
		var formdata=new FormData();
		var img = $('#imgSwiper').get(0).files[0];
		if (!img) {
			Snackbar.show({
				text: '请选择图片',
				pos: 'top-center'
			});
			return false;
		}
		formdata.append('img', img);
		$.ajax({
			async: false,
			type: 'POST',
			url: "/admin/uploadImg",
			dataType: 'json',
			data: formdata,
			contentType:false,//ajax上传图片需要添加
			processData:false,//ajax上传图片需要添加
			success: function (data) {
				if(data.code == "200"){
					$("#imgSwiperShowDiv").append("<div style=\"display: inline-grid;margin-right: 20px\"><div style=\"width:100%\"><img name='goodsSwiper' src='"+data.data+
							"' style='height:100px'/></div><div style=\"text-align: center\"><a onclick=\"delSwiperImg(this)\">删除</a></div></div>");
					$('#imgSwiper').val("");
				}
				else {
					$("#imgSwiperShowDiv").html("上传失败");
				}
			},
			error: function (e) {
				alert("error");
			}
		})
	}
	function delSwiperImg(val) {
		$(val).parent().parent().remove();
	}
	function add() {
		var priceAngel = 0;
		var priceCity = 0;
		var priceProvince = 0;
		var pricePartner = 0;

		var angelPrice = 0;
		var cityPrice = 0;
		var provincePrice = 0;
		var partnerPrice = 0;



		var options=$("#menuName option:selected");
		var mid = options.attr('mid');
		if(lx == 0){
			angelPrice = $("input[name='angelPrice']").val();
			if (!angelPrice) {
				Snackbar.show({
					text: '请输入天使价格',
					pos: 'top-center'
				});
				return false;
			}
			priceAngel = $("input[name='priceAngel']").val();
			if (!priceAngel) {
				Snackbar.show({
					text: '请输入天使返佣金额',
					pos: 'top-center'
				});
				return false;
			}
			cityPrice = $("input[name='cityPrice']").val();
			if (!cityPrice) {
				Snackbar.show({
					text: '请输入市代价格',
					pos: 'top-center'
				});
				return false;
			}
			priceCity = $("input[name='priceCity']").val();
			if (!priceCity) {
				Snackbar.show({
					text: '请输入市代返佣金额',
					pos: 'top-center'
				});
				return false;
			}
			provincePrice = $("input[name='provincePrice']").val();
			if (!provincePrice) {
				Snackbar.show({
					text: '请输入省代价格',
					pos: 'top-center'
				});
				return false;
			}
			priceProvince = $("input[name='priceProvince']").val();
			if (!priceProvince) {
				Snackbar.show({
					text: '请输入省代返佣金额',
					pos: 'top-center'
				});
				return false;
			}
			partnerPrice = $("input[name='partnerPrice']").val();
			if (!partnerPrice) {
				Snackbar.show({
					text: '请输入分公司价格',
					pos: 'top-center'
				});
				return false;
			}
			pricePartner = $("input[name='pricePartner']").val();
			if (!pricePartner) {
				Snackbar.show({
					text: '请输入分公司返佣金额',
					pos: 'top-center'
				});
				return false;
			}
		}
		var goodsName = $("input[name='goodsName']").val();
		if (!goodsName) {
			Snackbar.show({
				text: '请输入商品名称',
				pos: 'top-center'
			});
			return false;
		}
		var goodsPrices = $("input[name='goodsPrices']").val();
		if (!goodsPrices) {
			Snackbar.show({
				text: '请输入商品价格',
				pos: 'top-center'
			});
			return false;
		}
		var goodsSort =  $("input[name='goodsSort']").val();
		var goodsImg = $("img[name='goodsImg']").attr("src");
		if (!goodsImg) {
			Snackbar.show({
				text: '请上传商品主图',
				pos: 'top-center'
			});
			return false;
		}
		var goodsSwiper = [];
		$("img[name='goodsSwiper']").each(function() {
			goodsSwiper.push($(this).attr("src"));
		});
		if (!goodsSwiper) {
			Snackbar.show({
				text: '请上传商品轮播图',
				pos: 'top-center'
			});
			return false;
		}
		var goodsContent = UE.getEditor('goodsContent').getContent()
		if (!goodsContent) {
			Snackbar.show({
				text: '请输入商品详情',
				pos: 'top-center'
			});
			return false;
		}
		$.ajax({
			url: "/admin/addGoods",
			method: "POST",
			data: "goodsName=" + goodsName + "&goodsPrices=" + goodsPrices + "&goodsImg=" + goodsImg +
					"&goodsSwiper=" + goodsSwiper + "&goodsContent=" + goodsContent+"&goodsLx=" + lx+"&goodsMid=" + mid+"&priceAngel=" + priceAngel+"&priceCity=" + priceCity+"&priceProvince=" + priceProvince+"&pricePartner=" + pricePartner+"&angelPrice=" + angelPrice+"&cityPrice=" + cityPrice+"&provincePrice=" + provincePrice+"&partnerPrice=" + partnerPrice+"&goodsSort=" + goodsSort,
			dataType:"json",
			async: false,
			success: function (result) {
				if(result.code == "500"){
					Snackbar.show({
						text: result.msg,
						pos: 'top-center'
					});
					setTimeout(function (){
						window.location.reload();
					}, 1500);
				}else if(result.code == "200"){
					Snackbar.show({
						text: result.msg,
						pos: 'top-center'
					});
					window.location.href="/admin/shopGoodsList";
				}else if(result.code == "100"){
					Snackbar.show({
						text: "您已掉线！",
						pos: 'top-center'
					});
					setTimeout(function (){
						window.location.href="/admin/login";
					}, 1500);
				}
			},
			error : function() {
				Snackbar.show({
					text: '请稍后再试',
					pos: 'top-center'
				});
				setTimeout(function (){
					window.location.reload();
				}, 1500);
			}
		})
	}
</script>
<script src="/assets/js/custom.js"></script>
<!-- END GLOBAL MANDATORY SCRIPTS -->

<!-- BEGIN PAGE LEVEL CUSTOM SCRIPTS -->
<script src="/plugins/table/datatable/datatables.js"></script>
<!-- NOTE TO Use Copy CSV Excel PDF Print Options You Must Include These Files  -->
<script src="/plugins/table/datatable/button-ext/dataTables.buttons.min.js"></script>
<script src="/plugins/table/datatable/button-ext/jszip.min.js"></script>
<script src="/plugins/table/datatable/button-ext/buttons.html5.min.js"></script>
<script src="/plugins/table/datatable/button-ext/buttons.print.min.js"></script>


<!-- END PAGE LEVEL CUSTOM SCRIPTS -->
</body>
</html>
